package org.springframework.util;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class AntPathStringMatcher
{
  private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
  private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{([^/]+?)\\}");
  private final Pattern pattern;
  private String str;
  private final Map<String, String> uriTemplateVariables;
  private final List<String> variableNames = new LinkedList();

  AntPathStringMatcher(String paramString1, String paramString2, Map<String, String> paramMap)
  {
    this.str = paramString2;
    this.uriTemplateVariables = paramMap;
    this.pattern = createPattern(paramString1);
  }

  private Pattern createPattern(String paramString)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    Matcher localMatcher = GLOB_PATTERN.matcher(paramString);
    int i = 0;
    if (!localMatcher.find())
    {
      localStringBuilder.append(quote(paramString, i, paramString.length()));
      return Pattern.compile(localStringBuilder.toString());
    }
    localStringBuilder.append(quote(paramString, i, localMatcher.start()));
    String str1 = localMatcher.group();
    if ("?".equals(str1))
      localStringBuilder.append('.');
    while (true)
    {
      i = localMatcher.end();
      break;
      if ("*".equals(str1))
      {
        localStringBuilder.append(".*");
      }
      else if ((str1.startsWith("{")) && (str1.endsWith("}")))
      {
        int j = str1.indexOf(':');
        if (j == -1)
        {
          localStringBuilder.append("(.*)");
          this.variableNames.add(localMatcher.group(1));
        }
        else
        {
          String str2 = str1.substring(j + 1, -1 + str1.length());
          localStringBuilder.append('(');
          localStringBuilder.append(str2);
          localStringBuilder.append(')');
          String str3 = str1.substring(1, j);
          this.variableNames.add(str3);
        }
      }
    }
  }

  private String quote(String paramString, int paramInt1, int paramInt2)
  {
    if (paramInt1 == paramInt2)
      return "";
    return Pattern.quote(paramString.substring(paramInt1, paramInt2));
  }

  public boolean matchStrings()
  {
    Matcher localMatcher = this.pattern.matcher(this.str);
    if (localMatcher.matches())
    {
      if (this.uriTemplateVariables != null);
      for (int i = 1; ; i++)
      {
        if (i > localMatcher.groupCount())
          return true;
        String str1 = (String)this.variableNames.get(i - 1);
        String str2 = localMatcher.group(i);
        this.uriTemplateVariables.put(str1, str2);
      }
    }
    return false;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     org.springframework.util.AntPathStringMatcher
 * JD-Core Version:    0.6.2
 */